package cn.com.yunhe.controller;

import cn.com.yunhe.bean.CCarSystem;
import cn.com.yunhe.service.CCarSystemService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: 赵长松
 * @Date: 2019/1/10 10:41
 * @Version 1.0
 */
@Controller
public class CCarSystemController {
    @Resource
    private CCarSystemService carSystemService;
    /*
    *
    * //进入新增首页面
    * */
    @RequestMapping("/addCarStyleTem")
    public String addCarStyleTem(){
        return "houtai/ccarstyleadd";
    }
    /*
    *
    * //新增
    * */
    @RequestMapping("/addCarStyle")
    public String addCarStyle(CCarSystem carSystem){
        System.out.println("在控制层得到的数据："+carSystem);
        Integer integer = carSystemService.addCarStyle(carSystem);
        System.out.println("插入的状态为："+integer);
        return "houtai/ccarstylelist";
    }
    /*
    * //进入车系首页面
    *
    * */
    @RequestMapping("/carStyleLists")
    public String carStyleList(){
        return "houtai/ccarstylelist";
    }
    /*
    *
    *
    * 查询所有的数据
    *
    * */
    @RequestMapping("/querycarStyleList")
    @ResponseBody
    public List<CCarSystem> querycarstyle(CCarSystem carSystem){
        Map map = new HashMap();
        List<CCarSystem> cCarSystems = carSystemService.queryCarStyle(map);
        System.out.println("集合的个数为："+cCarSystems.size());
       /* if (cCarSystems.size()>0){
            for (CCarSystem style:cCarSystems) {
                if (style.getIsHot() ==0){
                    style.setCcsBy("否");
                }else{
                    style.setCcsBy("是");
                }
            }
        }*/
        
        return cCarSystems;
    }
    /*
    * //进入修改的页面
    *
    *
    * */
    @RequestMapping("/updateCarStyleTem")
    public void updateCarStyleTem(CCarSystem carSystem){
        CCarSystem cCarSystem = carSystemService.queryOneCarStyle(carSystem);
        System.out.println("查询出来要修改的数据为："+cCarSystem);
    }
    /*
    * 修改
    *
    *
    * */
    @RequestMapping("/updateCarStyle")
    public void updateCarStyle(CCarSystem carSystem){//修改
        System.out.println("修改传过来的数据："+carSystem);
        Integer integer = carSystemService.updateCarStyle(carSystem);
        System.out.println("修改状态为："+integer);
    }
    /*
    * //删除
    *
    *
    * */
    @RequestMapping("/delCarStyle")
    public void delCarStyle(CCarSystem carSystem){
        Integer integer = carSystemService.delteCarStyle(carSystem);
        System.out.println("删除状态为："+integer);
    }
}
